sdApp.controller("HomeController", function ($rootScope, $scope, homeData, $timeout) {
    $scope.topTopics = homeData.topics;
    $scope.topDecisions = homeData.decisions;
    $scope.count = homeData.counts;
    $scope.charts = homeData.carouselData;

    $scope.myInterval = 5000;

    $scope.chartData = [];

    _.each($scope.charts, function (data, index) {
        var getBindableData = function (options) {
            var processedData = {};
            processedData.data = [];
            _.each(options, function (option) {
                processedData.data.push({
                    x:option.answer,
                    tooltip: option.answer,
                    y: [option.votes]
                })
            });

            return processedData;
        }
        $scope.chartData[index] = getBindableData(data.options);
    });
    
    $scope.chartType = 'bar';

    $scope.config1 = {
        labels: false,
        xaxis: false,
        yaxis: false,
        tooltips: true,
        legend: {
            display: false,
            position: 'left'
        },
        innerRadius: 0
    };
    
    $timeout(function () {
        $scope.data1 = {
            series: ['Sales', 'Income', '<i>Expense</i>', 'Laptops', 'Keyboards'],
            data: [{
                x: "Sales",
                y: [100, 500, 0],
                tooltip: "this is tooltip"
            },
			{
			    x: "Not Sales",
			    y: [300, 100, 100]
			},
			{
			    x: "Tax",
			    y: [351]
			},
			{
			    x: "Not Tax",
			    y: [54, 0, 879]
			}]
        };
    }, 1000);
    
});
